package com.example.permissionservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.permissionservice.entity.UserRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface UserRoleMapper extends BaseMapper<UserRole> {

    @Select("SELECT * FROM user_roles WHERE user_id = #{userId}")
    UserRole findByUserId(@Param("userId") Long userId);

    @Select("SELECT role_code FROM roles r " +
            "JOIN user_roles ur ON r.role_id = ur.role_id " +
            "WHERE ur.user_id = #{userId}")
    String getRoleCodeByUserId(@Param("userId") Long userId);
}